<?php
/**
 * dbfront
 * (c) 2010-2013 Stephen Adkins <spadkins@gmail.com>
 * This software began development in 2010.
 * It is based on code dating from 1999.
 *
 * License: GPL 2.0
 * The contents of this file may be used under the terms of
 * the GNU General Public License Version 2 or later (the "GPL").
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 * */

require_once('frontstart.inc.php');   # defines: $options[], $context

$title        = $options['app.title'];
$namespace    = $options['app.namespace'];
# $favicon      = $options['favicon'];
$ext_urldir     = $options['ext_urldir'];
$shared_root  = $options['shared_root'];
$dbfront_root = '.';
$ext_jsfile   = $options['ext_jsfile'];
$ext_jsfile   = 'ext-dev.js';
$theme        = $options['theme'];

$themeinfo = array(
    'default' => array(
        'base_css'   => 'ext-all.css',
        'custom_css' => 'resources/theme/default/custom.css'
    ),
    'blue' => array(
        'base_css'   => 'ext-all.css',
        'custom_css' => 'resources/theme/default/custom.css'
    ),
    'gray' => array(
        'base_css'   => 'ext-all-gray.css',
        'custom_css' => 'resources/theme/default/custom.css'
    ),
    'neptune' => array(
        'base_css'   => 'ext-neptune.css',
        'custom_css' => 'resources/theme/default/custom.css'
    )
);
if (isset($themeinfo[$theme])) {
    $base_css   = $ext_urldir     . '/resources/css/' . $themeinfo[$theme]['base_css'];
    $custom_css = $dbfront_root . '/' . $themeinfo[$theme]['custom_css'];
}
else {
    $base_css   = $ext_urldir     . '/resources/css/ext-all.css';
    $custom_css = $dbfront_root . '/resources/theme/default/custom.css';
}

# http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.app.Application
# http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.app.Application
# http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-1/
# http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-2/

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo $title; ?></title>
    <link rel="stylesheet" type="text/css" href="<?php echo $base_css; ?>"/>     <!-- load the main Ext css file -->
    <link rel="stylesheet" type="text/css" href="<?php echo $custom_css; ?>"/>   <!-- load the custom css file that differs for each theme -->
    <link rel="stylesheet" type="text/css" href="resources/css/app.css"/>        <!-- load the custom css file that is independent of themes -->
<?php echo $context->initialJavascriptApplicationState() ?>                      <!-- initialize the FrontSuite namespace based on current logged-in user ('ff-auth' cookie) -->
    <script type="text/javascript" src="<?php echo $ext_urldir; ?>/<?php echo $ext_jsfile; ?>"></script>  <!-- load the main Ext file -->
    <script type="text/javascript" src="app.js"></script>  <!-- load the application file -->
</head>
<body>
</body>
</html>
